home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Environments / Clean 1.2.4 / PowerMacInterface / menus.icl < prev    next >
Encoding:
Modula Implementation  |  1996-12-23  |  4.2 KB  |  155 lines  |  [TEXT/3PRM]

  1. implementation module menus;
  2.  
  3. import mac_types;
  4.  
  5. //    Initialization and Allocation
  6.  
  7. InitMenus :: !Toolbox -> Toolbox;
  8. InitMenus t = code (t=U)(z=Z){
  9.     call    .InitMenus
  10. };
  11.  
  12. NewMenu :: !Int !{#Char} !Toolbox -> (!MacMenuHandle,!Toolbox);
  13. NewMenu menuID menuTitle t = code (menuID=D0,menuTitle=SD1,t=U)(newMenuHandle=D0,z=Z){
  14.     call    .NewMenu
  15. };
  16.  
  17. DisposeMenu :: !MacMenuHandle !Toolbox -> Toolbox;
  18. DisposeMenu theMenu t = code (theMenu=D0,t=U)(z=Z){
  19.     call    .DisposeMenu
  20. };
  21.  
  22. //    Forming the menus
  23.  
  24. AppendMenu :: !MacMenuHandle !{#Char} !Toolbox -> Toolbox;
  25. AppendMenu theMenu data t = code (theMenu=D0,data=SD1,t=U)(z=Z){
  26.     call    .AppendMenu
  27. };
  28.  
  29. AddResMenu :: !MacMenuHandle !Int !Toolbox -> Toolbox;
  30. AddResMenu theMenu theType t = code (theMenu=D0,theType=D1,t=U)(z=Z){
  31.     call    .AppendResMenu
  32. };
  33.  
  34. //    Forming the Menu Bar
  35.  
  36. InsertMenu :: !MacMenuHandle !Int !Toolbox -> Toolbox;
  37. InsertMenu theMenu beforeID t = code (theMenu=D0,beforeID=D1,t=U)(z=Z){
  38.     call    .InsertMenu
  39. };
  40.  
  41. ClearMenuBar :: !Toolbox -> Toolbox;
  42. ClearMenuBar t = code (t=U)(z=Z){
  43.     call    .ClearMenuBar
  44. };
  45.  
  46. DrawMenuBar :: !Toolbox -> Toolbox;
  47. DrawMenuBar t = code (t=U)(z=Z){
  48.     call    .DrawMenuBar
  49. };
  50.  
  51. DeleteMenu :: !Int !Toolbox -> Toolbox;
  52. DeleteMenu menuID t = code (menuID=D0,t=U)(z=Z){
  53.     call    .DeleteMenu
  54. };
  55.  
  56. CalcMenuSize :: !MacMenuHandle !Toolbox -> Toolbox;
  57. CalcMenuSize theMenu t = code (theMenu=D0,t=U)(z=Z){
  58.     call    .CalcMenuSize
  59. };
  60.  
  61. GetMHandle :: !Int !Toolbox -> (!MacMenuHandle,!Toolbox);
  62. GetMHandle menuID t = code (menuID=D0,t=U)(menu_handle=D0,z=Z){
  63.     call    .GetMenuHandle
  64. };
  65.  
  66. GetMenuBar :: !Toolbox -> (!Handle,!Toolbox);
  67. GetMenuBar t = code (t=U)(menu_list=D0,z=Z){
  68.     call    .GetMenuBar
  69. };
  70.  
  71. SetMenuBar :: !Handle !Toolbox -> Toolbox;
  72. SetMenuBar menu_list t = code (menu_list=D0,t=U)(z=Z){
  73.     call    .SetMenuBar
  74. };
  75.  
  76. InsMenuItem :: !MacMenuHandle !{#Char} !Int !Toolbox -> Toolbox;
  77. InsMenuItem theMenu itemString afterItem t = code (theMenu=D0,itemString=SD1,afterItem=D2,t=U)(z=Z){
  78.     call    .InsertMenuItem
  79. };
  80.  
  81. DelMenuItem :: !MacMenuHandle !Int !Toolbox -> Toolbox;
  82. DelMenuItem theMenu item t = code (theMenu=D0,item=D1,t=U)(z=Z){
  83.     call    .DeleteMenuItem
  84. };
  85.  
  86. //    Choosing From a Menu
  87.  
  88. MenuSelect :: !Int !Int !Toolbox -> (!Int,!Int,!Toolbox);
  89. MenuSelect h v t = code (h=D0,v=A0,t=U)(menu_ID=D1,menu_item=D0,z=Z){
  90.     instruction 0x52E3801E    | rlwimi    r3,r23,16,0,15
  91.     call    .MenuSelect
  92.     instruction    0x5464843E    | srwi        r4,r3,16
  93.     instruction 0x7063FFFF    | andi.        r3,r3,65535
  94. };
  95.  
  96. MenuKey :: !Int !Toolbox -> (!Int,!Int,!Toolbox);
  97. MenuKey char t = code (char=D0,t=U)(menu_ID=D1,menu_item=D0,z=Z){
  98.     call    .MenuKey
  99.     instruction    0x5464843E    | srwi    r4,r3,16
  100.     instruction 0x7063FFFF    | andi.    r3,r3,65535
  101. };
  102.  
  103. HiliteMenu :: !Int !Toolbox -> Toolbox;
  104. HiliteMenu menuID t = code (menuID=D0,t=U)(z=Z){
  105.     call    .HiliteMenu
  106. };
  107.  
  108. PopUpMenuSelect :: !MacMenuHandle !Int !Int !Int !Toolbox -> (!Int,!Int,!Toolbox);
  109. PopUpMenuSelect menu top left popUpItem t
  110. = code (menu=D0,top=D1,left=D2,popUpItem=D3,t=U)(menu_ID=D1,menu_item=D0,z=Z){
  111.     call    .PopUpMenuSelect
  112.     instruction    0x5464843E    | srwi    r4,r3,16
  113.     instruction 0x7063FFFF    | andi.    r3,r3,65535
  114. };
  115.  
  116. //    Controlling the Appearance of Items
  117.  
  118. SetItem :: !MacMenuHandle !Int !{#Char} !Toolbox -> Toolbox;
  119. SetItem theMenu item itemString t = code (theMenu=D0,item=D1,itemString=SD2)(z=Z){
  120.     call    .SetMenuItemText
  121. };
  122.  
  123. GetItem :: !MacMenuHandle !Int !{#Char} !Toolbox -> (!{#Char},!Toolbox);
  124. GetItem theMenu item s tb = (GetItem1 theMenu item s tb, NewToolbox);
  125.  
  126. GetItem1 :: !MacMenuHandle !Int !{#Char} !Toolbox -> {#Char};
  127. GetItem1 theMenu item s t = code (theMenu=D0,item=D1,s=U,t=U)(itemString=A0){
  128.     instruction 0x3AA00000    |    li        r21,0
  129.     instruction 0x92B70004    |    stw        r21,4(r23)
  130.     instruction 0x38B70007    |    addi    r5,r23,7
  131.     call    .GetMenuItemText
  132. };
  133.  
  134. DisableItem :: !MacMenuHandle !Int !Toolbox -> Toolbox;
  135. DisableItem theMenu item t = code (theMenu=D0,item=D1,t=U)(z=Z){
  136.     call    .DisableItem
  137. };
  138.  
  139. EnableItem :: !MacMenuHandle !Int !Toolbox -> Toolbox;
  140. EnableItem theMenu item t = code (theMenu=D0,item=D1,t=U)(z=Z){
  141.     call    .EnableItem
  142. };
  143.  
  144. CheckItem :: !MacMenuHandle !Int !Bool !Toolbox -> Toolbox;
  145. CheckItem theMenu item checked t = code (theMenu=D0,item=D1,checked=D2,t=U)(z=Z){
  146.     call    .CheckItem
  147. };
  148.  
  149. //    Miscellaneous Routines
  150.  
  151. CountMItems :: !MacMenuHandle !Toolbox -> (!Int,!Toolbox);
  152. CountMItems theMenu tb = code (theMenu=D0,tb=U)(count=D0,z=Z){
  153.     call    .CountMItems
  154. };
  155.